package com.zte.claa.inficombo.csa.app.service.rescmd.impl;

import java.util.HashMap;
import java.util.Map;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.DisposableBean;
import org.springframework.beans.factory.InitializingBean;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.zte.claa.inficombo.csa.app.service.huaxiapr.HuaXiaRmPlateRecogService;
import com.zte.claa.inficombo.csa.app.service.rescmd.ResDevCmdParser;
import com.zte.claa.inficombo.csa.app.service.rescmd.parsers.HuaXiaRmResDevCmdParser;

@Service
public class ResCommandContainer implements InitializingBean, DisposableBean {
	private final Logger logger = LoggerFactory.getLogger(ResCommandContainer.class);
		
	private Map<String, ResDevCmdParser> cmdParserMap = new HashMap<String, ResDevCmdParser>();
	
	@Autowired
	private HuaXiaRmPlateRecogService huaXiaService;
	
	@Override
	public void afterPropertiesSet() throws Exception {
		//新增  华夏相机逻辑资源命令下发处理器
		HuaXiaRmResDevCmdParser huaxia_resdev_parser = new HuaXiaRmResDevCmdParser();
		huaxia_resdev_parser.setParserContainer(this);
		this.cmdParserMap.put(huaxia_resdev_parser.getDevType(), huaxia_resdev_parser);	
		logger.info("Register devtype:"+ huaxia_resdev_parser.getDevType() + " successfully!");
	}
	
	@Override
	public void destroy() throws Exception {
		;
	}

	public ResDevCmdParser getParserByResDevtype(String devtype){
		if(devtype == null){
			return null;
		}else{
			return this.cmdParserMap.get(devtype);
		}
		
	}
	
	public HuaXiaRmPlateRecogService getHuaXiaService() {
		return huaXiaService;
	}

	public Map<String, ResDevCmdParser> getCmdParserMap() {
		return cmdParserMap;
	}	
}

